//
//  OrderDetailTableViewCell.m
//  Shoes365
//
//  Created by CJX on 16/9/9.
//  Copyright © 2016年 Shanghai DuRui Information Technology Company. All rights reserved.
//

#import "OrderDetailTableViewCell.h"

@implementation OrderDetailTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        _productNameLabel = [[UILabel alloc]init];
        if (iPhone5) {
            _productNameLabel.font = [UIFont systemFontOfSize:13];
        }else{
            _productNameLabel.font = [UIFont systemFontOfSize:15];
        }
        _productNameLabel.numberOfLines = 0;
        [self addSubview:_productNameLabel];
        [_productNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.offset(5);
            make.left.offset(15);
            make.right.offset(-15);
            make.height.equalTo(self.mas_height).multipliedBy(0.5);
        }];
        
        _attributeLabel = [[UILabel alloc]init];
        if (iPhone5) {
            _attributeLabel.font = [UIFont systemFontOfSize:12];
        }else{
            _attributeLabel.font = [UIFont systemFontOfSize:13];
        }
        _attributeLabel.textColor = [UIColor grayColor];
        _attributeLabel.textAlignment = NSTextAlignmentLeft;
        [self addSubview:_attributeLabel];
        [_attributeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_productNameLabel.mas_bottom).offset(5);
            make.left.offset(15);
            make.width.equalTo(self.mas_width).multipliedBy(0.7);
            make.height.equalTo(self.mas_height).multipliedBy(0.3);
        }];
        
        _priceLabel = [[UILabel alloc]init];
        if (iPhone5) {
            _priceLabel.font = [UIFont systemFontOfSize:12];
        }else{
            _priceLabel.font = [UIFont systemFontOfSize:13];
        }
        _priceLabel.textColor = [UIColor grayColor];
        _priceLabel.textAlignment = NSTextAlignmentRight;
        [self addSubview:_priceLabel];
        [_priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_productNameLabel.mas_bottom).offset(5);
            make.left.equalTo(_attributeLabel.mas_right).offset(5);
            make.bottom.equalTo(_attributeLabel.mas_bottom);
            make.right.offset(-15);
        }];
        
        _qtyLabel = [[UILabel alloc]init];
        if (iPhone5) {
            _qtyLabel.font = [UIFont systemFontOfSize:11];
        }else{
            _qtyLabel.font = [UIFont systemFontOfSize:12];
        }
        _qtyLabel.textColor = [UIColor grayColor];
        _qtyLabel.textAlignment = NSTextAlignmentRight;
        [self addSubview:_qtyLabel];
        [_qtyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_priceLabel.mas_bottom);
            make.right.offset(-15);
            make.bottom.offset(-3);
            make.left.offset(0);
        }];
        
        
    }
    return self;
}

-(void)setModel:(OrderHistoryModel *)model{
    _productNameLabel.text = model.products_name;
    _attributeLabel.text = [NSString stringWithFormat:@"%@:%@",model.option,model.value];
    _priceLabel.text = [NSString stringWithFormat:@"%@",model.price];
    _qtyLabel.text = [NSString stringWithFormat:@"×%@",model.qty];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
